const contentShow = data => {
  let ContentEdit = "";
  const { sceneTemplateRules = [] } = data;
  if (sceneTemplateRules !== null) {
    sceneTemplateRules.forEach(item => {
      if (item.messageType === 0) {
        ContentEdit += item.messageContent;
      }
      if (
        item.messageType === 1 &&
        item.messageUnitName !== "position" &&
        item.messageUnitName !== "similarity"
      ) {
        ContentEdit += `{${item.messageParameter}}`;
      }
    });
  }
  return ContentEdit;
};

const getUrl = data => {
  const urlPic = [];
  const { sceneTemplateRules = [] } = data;
  if (sceneTemplateRules !== null) {
    sceneTemplateRules.forEach(item => {
      if (item.messageType === 2) {
        urlPic.push(`${item.messageParameter}；`);
      }
    });
  }
  return urlPic;
};

const getNoContent = data => {
  const { sceneTemplateRules = [] } = data;
  let noCon = "-";
  if (sceneTemplateRules && sceneTemplateRules.length > 0) {
    noCon =
      sceneTemplateRules[0].parameterNullContent === ""
        ? "-"
        : sceneTemplateRules[0].parameterNullContent;
  }
  return noCon;
};

export default { contentShow, getUrl, getNoContent };
